package pcjavanet.mobilesell.web.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import pcjavanet.mobilesell.model.Sale;
import pcjavanet.mobilesell.model.PageBean;
import pcjavanet.mobilesell.model.QryCondition;
import pcjavanet.mobilesell.service.SaleService;

import com.opensymphony.xwork2.ActionSupport;
@Namespace("/sale")
@Controller
@Scope("prototype")
@ParentPackage("json-default")
@Results({
	@Result(name = "success", location = "/view/Sale.jsp"),
	@Result(name = "input", location = "/view/Sale.jsp")
})

public class SaleAction  extends ActionSupport {

  @Resource
  private SaleService saleService;
  private   java.lang.Integer dbid ;
  private   java.lang.Integer refGoodsDbid ;
  private   java.lang.Integer refColorDbid ;
  private   java.lang.Integer refConfigurationDbid ;
  private   java.lang.String peisong ;
  private   java.lang.Double unitprice ;
  private   java.lang.Double money ;
  private   java.lang.Double status ;
  private   java.lang.String memo ;
  private   java.util.Date createDate ;
  private int start  ;
  private int limit  ;
  private int totalProperty  ;
  private boolean success = true ;
  private String  info ;
  private List<Sale>  salePageBeans  ;
  public    java.lang.Integer getDbid() {
   	return this.dbid;
  }
  public void setDbid(  java.lang.Integer  dbid) {
   	 this.dbid=dbid;
  }
  public    java.lang.Integer getRefGoodsDbid() {
   	return this.refGoodsDbid;
  }
  public void setRefGoodsDbid(  java.lang.Integer  refGoodsDbid) {
   	 this.refGoodsDbid=refGoodsDbid;
  }
  public    java.lang.Integer getRefColorDbid() {
   	return this.refColorDbid;
  }
  public void setRefColorDbid(  java.lang.Integer  refColorDbid) {
   	 this.refColorDbid=refColorDbid;
  }
  public    java.lang.Integer getRefConfigurationDbid() {
   	return this.refConfigurationDbid;
  }
  public void setRefConfigurationDbid(  java.lang.Integer  refConfigurationDbid) {
   	 this.refConfigurationDbid=refConfigurationDbid;
  }
  public    java.lang.String getPeisong() {
   	return this.peisong;
  }
  public void setPeisong(  java.lang.String  peisong) {
   	 this.peisong=peisong;
  }
  public    java.lang.Double getUnitprice() {
   	return this.unitprice;
  }
  public void setUnitprice(  java.lang.Double  unitprice) {
   	 this.unitprice=unitprice;
  }
  public    java.lang.Double getMoney() {
   	return this.money;
  }
  public void setMoney(  java.lang.Double  money) {
   	 this.money=money;
  }
  public    java.lang.Double getStatus() {
   	return this.status;
  }
  public void setStatus(  java.lang.Double  status) {
   	 this.status=status;
  }
  public    java.lang.String getMemo() {
   	return this.memo;
  }
  public void setMemo(  java.lang.String  memo) {
   	 this.memo=memo;
  }
  public    java.util.Date getCreateDate() {
   	return this.createDate;
  }
  public void setCreateDate(  java.util.Date  createDate) {
   	 this.createDate=createDate;
  }
  public  void setStart(int start) {
   	 this.start = start;
  }
  public  void setLimit(int limit) {
   	 this.limit = limit;
  }
  public  void setTotalProperty(int totalProperty) {
   	 this.totalProperty = totalProperty;
  }
  public  void setSalePageBeans(List<Sale> salePageBeans){
   	 this.salePageBeans =salePageBeans  ;
  }
  public  int getStart( ) {
   	 return this.start;
  }
  public  int getLimit( ) {
   	 return this.limit;
  }
  public  int getTotalProperty( ) {
   	 return this.totalProperty;
  }
  public    List<Sale> getSalePageBeans(){
   	 return this.salePageBeans   ;
  }
  public  String getInfo( ) {
   	 return this.info;
  }
  public  void setInfo(String info){
   	 this.info = info ;
  }
  public  boolean getSuccess( ) {
   	 return this.success;
  }
  public  void setSuccess(boolean success){
   	 this.success = success ;
  }

  @Action(value="insertSale",results = {@Result(name = "success", type = "json")})
  public String  insertSale() throws Exception{
   	success = false ;
   	info = "" ;
  	Sale bean = new Sale();
  	bean.setRefGoodsDbid(this.refGoodsDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setPeisong(this.peisong); 
  	bean.setUnitprice(this.unitprice); 
  	bean.setMoney(this.money); 
  	bean.setStatus(this.status); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
	saleService.insert(bean);
   	success = true ;
   	info = "Add Successful" ;
   	return SUCCESS;
  }

  @Action(value="querySale",results = {@Result(name = "success", type = "json")})
  public String  querySale() throws Exception{
  	Sale bean = new Sale();
  	bean.setDbid(this.dbid); 
  	bean.setRefGoodsDbid(this.refGoodsDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setPeisong(this.peisong); 
  	bean.setUnitprice(this.unitprice); 
  	bean.setMoney(this.money); 
  	bean.setStatus(this.status); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
	saleService.selectByPrimaryKey(bean);
   	return SUCCESS;
  }

  @Action(value="updateSale",results = {@Result(name = "success", type = "json")})
  public String  updateSale() throws Exception{
   	success = false ;
   	info = "" ;
  	Sale bean = new Sale();
  	bean.setDbid(this.dbid); 
  	bean.setRefGoodsDbid(this.refGoodsDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setPeisong(this.peisong); 
  	bean.setUnitprice(this.unitprice); 
  	bean.setMoney(this.money); 
  	bean.setStatus(this.status); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
  	bean =saleService.selectByPrimaryKey(bean);
  	bean.setDbid(this.dbid); 
  	bean.setRefGoodsDbid(this.refGoodsDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setPeisong(this.peisong); 
  	bean.setUnitprice(this.unitprice); 
  	bean.setMoney(this.money); 
  	bean.setStatus(this.status); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
	saleService.updateByPrimaryKeySelective(bean);
   	success = true ;
   	info = "Update Successful" ;
   	return SUCCESS;
  }

  @Action(value="deleteSale",results = {@Result(name = "success", type = "json")})
  public String  deleteSale() throws Exception{
  	Sale bean = new Sale();
  	bean.setDbid(this.dbid); 
  	bean.setRefGoodsDbid(this.refGoodsDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setPeisong(this.peisong); 
  	bean.setUnitprice(this.unitprice); 
  	bean.setMoney(this.money); 
  	bean.setStatus(this.status); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
	saleService.deleteByPrimaryKey(bean);
   	return SUCCESS;
  }

  @Action(value="listSale",results = {@Result(name = "success", type = "json")})
  public String  listSale() throws Exception{
 	QryCondition qry = RequestUtil.getQryCondition(   (javax.servlet.http.HttpServletRequest)com.opensymphony.xwork2.ActionContext.getContext().get(org.apache.struts2.ServletActionContext.HTTP_REQUEST)); 	PageBean pageBean = new PageBean();
	pageBean.setPageSize( limit );
	pageBean.setStartCount( start );
	totalProperty =saleService.getTotalRecords( qry, pageBean );
	salePageBeans =saleService.getOnePageBeans( qry, pageBean );
   	return SUCCESS;
  }

  @Action("index")
  public String index() throws Exception{
   	return SUCCESS;
  }

}
